package ar.com.equis.flexjavaintegration.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import ar.com.equis.flexjavaintegration.dao.GenericDAOHibernateImplementation;

public class GenericServiceImplementacion<T,K extends GenericDAOHibernateImplementation<T>> implements IGenericService<T>{

	protected K dao; 
	
	@Override
	@Transactional
	public Serializable save(T entity) {
		return dao.save(entity);
	}

	@Override
	@Transactional
	public void delete(T entity) {
		dao.delete(entity);
	}

	@Override
	public List<T> findAll() {
		return dao.findAll();
	}

	@Override
	@Transactional
	public void saveOrUpdate(T entity) {
		dao.saveOrUpdate(entity);	
	}

	@Override
	@Transactional
	public void persist(T entity) {
		dao.persist(entity);		
	}

	@Override
	public T load(Serializable id) {
		return dao.load(id);
	}

	@Override
	@Transactional
	public void update(T entity) {
		dao.update(entity);
	}

	@Autowired
	public void setDao(K dao) {
		this.dao = dao;
	}

	
}
